<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="/css/pintuer.css">
    <link rel="stylesheet" href="/css/admin.css">
    <script src="/js/jquery.js"></script>
    <script src="/js/pintuer.js"></script>
    <script src="/js/vuejs-2.5.16.js"></script>
    <script src="/js/axios-0.18.0.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="/element-ui/lib/index.js"></script>


</head>
<body>
<div class="panel admin-panel" id="moviesListDiv">
    <div class="panel-head"><strong class="icon-reorder"> 用户列表</strong> <a href="" style="float:right; display:none;">添加字段</a>
    </div>
    <div class="padding border-bottom">
        <form>
            <ul class="search" style="padding-left:10px;">
                <li>搜索：</li>
                <li>
                    <select name="cid" class="input" style="width:200px; line-height:17px;" v-model="cid">
                        <option value="">请选择性别</option>
                        <option value="1">男性</option>
                        <option value="2">女性</option>
                    </select>
                </li>
                <li>
                    <input type="text" placeholder="请输入目标地区" name="keyword" class="input"
                           style="width:250px; line-height:17px;display:inline-block" v-model="keyWord"/>
                    <a class="button border-main icon-search" @click="findByPage()"> 搜索</a></li>
            </ul>
        </form>
    </div>
    <table class="table table-hover text-center">
        <tr>
            <th width="5%">编号</th>
            <th>用户ID</th>
            <th>用户昵称</th>
            <th width="10%">性别</th>
            <th>居住地</th>
            <th>状态</th>
            <th width="310">最后活跃地点</th>
        </tr>

        <tr v-for="user in pagination.items">
            <td>{{user.count}}</td>
            <td>{{user.id}}</td>
            <td>{{user.nickname}}</td>
            <!--    <td>高观看率</td>
                    <td>高评分率</td>
                    <td>最新上映</td>-->
            <td>{{user.gender}}</td>
            <td>{{user.city}}</td>
            <td>{{user.userState}}</td>
            <td>
                <div class="button-group">
                    <a class="button border-main" v-bind:href="'/map1.html?userId='+user.id"><span class="icon-edit"></span>查看</a>
                </div>
            </td>
        </tr>

        <tr>
            <td colspan="7" style="text-align:left;padding-left:20px;">
                <span>总记录数：{{this.pagination.counts}}</span>
            </td>
        </tr>
        <tr>
            <td colspan="8">
                <div class="pagelist" >
                    <!--分页组件-->
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.page"
                            :page-size="pagination.pagesize"
                            :total="pagination.counts"
                            background
                            layout="prev, pager, next">
                    </el-pagination>
                </div>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">

    const app = new Vue({
        el: '#moviesListDiv',
        data: {
            pagination: { // 分页对象
                counts: 20,
                pagesize: 10,
                pages:'',
                page: 1,
                items: [],
            },
            count: 1,
            keyWord:'',
            cid:'',
        },
        methods: {
			// 分页查询
            findByPage() {
                axios.get('http://localhost:18088/houtai/manage/users',{
                    headers:{
                        Authorization:localStorage.getItem("Authorization")
                    },
                    params:{
                        page:this.pagination.page,
                        pagesize:this.pagination.pagesize,
                        cid:this.cid,
                        keyWord: this.keyWord,
                    }
                }).then(resp=>{
                    this.pagination = resp.data;
                })
            },
            //当前页改变时调用的方法
            handleCurrentChange(pageNum) {
                //将最新页码赋值给分页对象的当前页码
                this.pagination.page = pageNum;
                //重新发起分页请求
                this.findByPage();
            },
            //改变每页大小时调用的方法
            handleSizeChange(pageSize) {
                //将最新的每页大爱小赋值给分页对象的当前页码
                this.pagination.pagesize = pageSize;
                //重新发起分页请求
                this.findByPage();
            },
        },
        created(){
            this.findByPage();
            console.log(this.pagination)
        }
    })
</script>
<script src="/js/verify.js"></script>
</body>
</html>